
 
 /*
 The following codes will replicate the results in Table 5 in the main text.
 
 Note that the following codes only generate columns 2-17 in Table 5,
 while column 1 is directly from Table 3.
 */
 
 
*-------------------------------------------------------------
* Table 5 
*--------------------------------------------------------------

use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_mechanism", clear
replace indc_e=0 if indc_e==.
replace indc_abt=0 if indc_abt==.
*replace cic_so2=0 if cic_so2==.

replace exp_e=exp_dummy2*indc_e
replace exp_abt=exp_dummy2*indc_abt
replace exp_index1=exp_dummy2*cic_so2

capture drop IV1 
capture drop IV2
capture drop  IV3 
capture drop IV4

gen IV1=exp_dummy_lag *RD_d
gen IV2=exp_dummy_lag *coal_share_lag
gen IV3=exp_dummy_lag *lnv_lag
gen IV4=exp_dummy_lag *dirty_so2
gen IV5=exp_dummy_lag *indc_e
gen IV6=exp_dummy_lag *indc_abt
gen IV7=exp_dummy_lag*cic_so2

rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename lnv_lag vintage
rename exp_v exp_vintage
rename tfp_acf_new Productivity
rename coal_share_lag NRG
rename exp_coal exp_NRG
rename dirty_so2 Mix
rename exp_so2 exp_mix
rename RD_d RD
rename lnkl_lag lnKL
rename lntariff Tariff
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod
rename cic_so2 Demand
 
/*
* compute R2
predict y_hat, xb
egen y_bar=mean(lnso2)

gen diff1=(y_hat-y_bar)^2
egen SSR=sum(diff1)

gen diff2=(lnso2-y_bar)^2
egen SST=sum(diff2)

gen R2=SSR/SST 
sum R2
drop R2 y_hat y_bar diff1 diff2 SST SSR
*/

*----------------------------------------
* 5.1 RD IV: columns 2-3 of Table 5
*----------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation ) RD  Productivity Tariff lnKL  lnso2_ini  , a(cic prov year ownership) cluster(prov_c)
ivreghdfe lnso2  (Export Abatement_so2 exp_rd =tariff_prod ventilation_prod  ventilation  ventilation  IV1) RD  Productivity Tariff lnKL  lnso2_ini, a(cic  prov year ownership) cluster(prov_c)
*******************************************************



*-------------------------------------------------  
* 5.2 capital vintage IV:  columns 4-5 of Table 5
*----------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation) vintage Productivity Tariff lnKL  lnso2_ini  , a(cic  prov year ownership) cluster(prov_c)

ivreghdfe lnso2  (Export Abatement_so2 exp_vintage=tariff_prod ventilation_prod  ventilation exp_dummy_lag IV3) vintage Productivity Tariff lnKL  lnso2_ini, a(cic  prov year ownership) cluster(prov_c)

**************************************************************

*-------------------------------------------------
*5.3 energy share IV:  columns 6-7 of Table 5
*------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation ) NRG Productivity Tariff lnKL  lnso2_ini , a(cic  prov year ownership) cluster(prov_c)

ivreghdfe lnso2  (Export Abatement_so2 exp_NRG=tariff_prod ventilation_prod  ventilation exp_dummy_lag IV2)  NRG Productivity Tariff lnKL  lnso2_ini, a(cic  prov year ownership) cluster(prov_c)

***************************************************************



*--------------------------------------------------------
* 5.4 Energy import share: columns 8-9 of Table 5
*-------------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation ) indc_e  Productivity Tariff lnKL  lnso2_ini  , a(cic prov year ownership) cluster(prov_c)

ivreghdfe lnso2  (Export Abatement_so2 exp_e =tariff_prod ventilation_prod  ventilation  ventilation  IV5) indc_e  Productivity Tariff lnKL  lnso2_ini, a(cic  prov year ownership) cluster(prov_c)
*********************************************************************************************************************************************************************************************************

*----------------------------------------------------
*5.5 Import abatement IV:  columns 10-11 of Table 5
*----------------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation ) indc_abt Productivity Tariff lnKL  lnso2_ini , a(cic  prov year ownership) cluster(prov_c)

ivreghdfe lnso2  (Export Abatement_so2 exp_abt= ventilation_prod  ventilation exp_dummy_lag IV6)  indc_abt Productivity Tariff lnKL  lnso2_ini, a(cic  prov year ownership) cluster(prov_c)




***************************************************************************************************************

*---------------------------------------------
*5.6 product-mix IV: columns 12-13 of Table 5
*---------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation) Mix Productivity Tariff lnKL  lnso2_ini  , a(cic  prov year ownership) cluster(prov_c)

ivreghdfe lnso2  (Export Abatement_so2 exp_mix=tariff_prod ventilation_prod  ventilation exp_dummy_lag IV4) Mix Productivity Tariff lnKL  lnso2_ini  , a(cic  prov year ownership) cluster(prov_c)

*************************************************************


*----------------------------------------------------------------
use  "D:\Nanjing\2019\pollution2\submission\files for submission\data\environ_index", clear
*-----------------------------------------------------------

* gen IVs for interaction term
capture drop IV1 
capture drop IV2
capture drop  IV3 
capture drop IV4


gen IV1=exp_dummy_lag *cic_so2
gen IV2=exp_dummy_lag *cic_co2


rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename lnv_lag vintage
rename exp_v exp_vintage
rename tfp_acf_new Productivity
rename coal_share_lag NRG
rename exp_coal exp_NRG
rename dirty_so2 Mix
rename exp_so2 exp_mix
rename RD_d RD
rename lnkl_lag lnKL
rename lntariff Tariff
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod

rename cic_so2 Demand

*---------------------------------------------
*5.7 RD IV: columns 14-15 of Table 5
*---------------------------------------------
ivreghdfe lnso2  (Export Abatement_so2 =tariff_prod ventilation_prod  ventilation ) Demand Productivity Tariff lnKL  lnso2_ini  , a(cic prov year ownership) cluster(prov_c)

ivreghdfe lnso2  (Export Abatement_so2 exp_index1 =tariff_prod ventilation_prod  ventilation   IV1) Demand Productivity Tariff lnKL  lnso2_ini, a(cic  prov year ownership) cluster(prov_c)
*******************************************************



use "D:\Nanjing\2019\pollution2\submission\files for submission\data\tables_mechanism_full", clear
replace indc_e=0 if indc_e==.
replace indc_abt=0 if indc_abt==.
*replace cic_so2=0 if cic_so2==.

replace exp_e=exp_dummy2*indc_e
replace exp_abt=exp_dummy2*indc_abt
replace exp_index1=exp_dummy2*cic_so2

capture drop IV1 
capture drop IV2
capture drop  IV3 
capture drop IV4

gen IV1=exp_dummy_lag *RD_d
gen IV2=exp_dummy_lag *coal_share_lag
gen IV3=exp_dummy_lag *lnv_lag
gen IV4=exp_dummy_lag *dirty_so2
gen IV5=exp_dummy_lag *indc_e
gen IV6=exp_dummy_lag *indc_abt
gen IV7=exp_dummy_lag*cic_so2

rename exp_dummy2 Export
rename so2_new1 Abatement_so2
rename dust_new1 Abatement_dust
rename lnv_lag vintage
rename exp_v exp_vintage
rename tfp_acf_new Productivity
rename coal_share_lag NRG
rename exp_coal exp_NRG
rename dirty_so2 Mix
rename exp_so2 exp_mix
rename RD_d RD
rename lnkl_lag lnKL
rename lntariff Tariff
rename treatment_tfp tariff_prod
rename treatment_so2 ventilation_prod
rename cic_so2 Demand
egen ub=pctile(lnso2), p(98)
*-------------------------------
* 5.8. columns 16-17 of Table 5
*------------------------------
ivreghdfe lnso2  (Export Abatement_so2=tariff_prod ventilation_prod  ventilation ) RD NRG vintage Mix  indc_e  indc_abt Demand Productivity Tariff lnKL  lnso2_ini if lnso2<ub, a(cic prov year ownership)  cluster(prov_c)


ivreghdfe lnso2  (Export Abatement_so2 exp_rd exp_NRG exp_vintage exp_mix  exp_e exp_abt exp_index1=tariff_prod ventilation_prod  ventilation exp_dummy_lag IV1 IV2 IV3 IV4 IV5 IV6 IV7)  RD NRG vintage Mix indc_e  indc_abt Demand  Productivity Tariff lnKL  lnso2_ini if lnso2<ub , a(cic prov year ownership) cluster(prov_c)




